#!/bin/bash
echo "Usage: $0 passwd input out [-d]";


if [ "$#" != "3" ] && [ "$#" != "4" ]; then
  exit;
fi

echo "passwd: $1";
KEY=$(echo -n "$1" | sha256sum);
KEY=${KEY:0:64};
echo "KEY: $KEY";

echo "in: $2";
echo "out: $3";
echo "addition: $4";

echo "processing...";
openssl enc -aes-256-cbc -nosalt $4 -K "$KEY" -iv "00000000000000000000000000000000" -in "$2" -out "$3"
